package father

import (
	"github.com/gin-gonic/gin"
	"strings"
)

func RawString(ctx *gin.Context, key string) string {
	val := ctx.Query(key)
	if strings.Trim(val, " ") != "" {
		return val
	}
	if raw, ok := ctx.Get("RawAny"); ok {
		if raw_map, ok := raw.(map[string]any); ok {
			val, ok = raw_map[key].(string)
			return val
		}
	}
	return ""
}

func RawAny(ctx *gin.Context, key string) any {
	val := ctx.Query(key)
	if strings.Trim(val, " ") != "" {
		return val
	}
	if raw, ok := ctx.Get("RawAny"); ok {
		if raw_map, ok := raw.(map[string]any); ok {
			return raw_map[key]
		}
	}
	return ""
}

func Raw(ctx *gin.Context) map[string]any {
	if raw, ok := ctx.Get("RawAny"); ok {
		if raw_map, ok := raw.(map[string]any); ok {
			return raw_map
		}
	}
	return nil
}
